package com.assistant.framework;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.util.List;
import java.util.Optional;

public interface BaseGateway<T extends BaseDomain<?>> {

    T getById(Long id);

    Optional<T> findById(Long id);

    List<T> findAllById(Iterable<Long> ids);

    List<T> findAll();

    List<T> findAll(Sort sort);

    <S extends T> List<S> findAll(Example<S> example);

    <S extends T> List<S> findAll(Example<S> example, Sort sort);

    Page<T> findAll(Pageable pageable);

    boolean existsById(Long id);

    long count();

    T save(T entity);

    <S extends T> Iterable<S> saveAll(Iterable<S> entities);

    void delete(T entity);

    void deleteById(Long id);

    void deleteAllById(Iterable<? extends Long> ids);

    void deleteAllByIdInBatch(Iterable<Long> ids);

    void deleteAll(Iterable<? extends T> entities);

    void deleteAllInBatch(Iterable<T> entities);
}
